package www.woniuxy.com.class112.controller;

import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import www.woniuxy.com.class112.form.issues.AdminAddIssuesForm;
import www.woniuxy.com.class112.form.issues.AssignAgentForm;
import www.woniuxy.com.class112.form.issues.SelectIssuesForm;
import www.woniuxy.com.class112.param.issues.AdminAddIssuesParam;
import www.woniuxy.com.class112.param.issues.AssignAgentParam;
import www.woniuxy.com.class112.param.issues.SelectIssuesParam;
import www.woniuxy.com.class112.service.IssuesService;
import www.woniuxy.com.class112.util.Result;

import javax.annotation.Resource;


@RestController
@RequestMapping("/issues")
@Api(tags = "问题相关接口")
public class IssuesController {
    @Resource
    private IssuesService issuesService;
    @PostMapping("/selectIssues")
    @ApiOperation("分页查询问题")
    public Result selectIssues(@RequestBody SelectIssuesForm form)throws Exception{
        SelectIssuesParam param = BeanUtil.toBean(form, SelectIssuesParam.class);

        return Result.success("查询成功",issuesService.selectIssues(param));
    }
    @PostMapping("/addIssues")
    @ApiOperation("管理员新增问题")
    public Result addIssue(@RequestBody AdminAddIssuesForm form)throws Exception{
        System.out.println(form);
            issuesService.addIssue(BeanUtil.toBean(form, AdminAddIssuesParam.class));
        return  Result.success("新增成功",null);

    }
    @PostMapping("/assignAgent")
    @ApiOperation("管理员分配特派员")
    public Result assignAgent(@RequestBody AssignAgentForm form)throws Exception{
        issuesService.assignAgent(BeanUtil.toBean(form, AssignAgentParam.class));
        return Result.success("分配成功",null);
    }


}
